package com.arron.algorithm.huawei;

import java.util.*;
import java.util.regex.Pattern;

public class 正则表达式的使用 {

    public static void main(String[] args) {
        String str = "cc11212";
        String p1 = "[a-z]+";
        String p2 = "[A-Z]+";
        String p3 = "[0-9]+";
        Pattern pattern1 = Pattern.compile(p1);
        Pattern pattern2 = Pattern.compile(p2);
        Pattern pattern3 = Pattern.compile(p3);
//        System.out.println(pattern1.matcher(str).find());
//        System.out.println(pattern2.matcher(str).find());
//        System.out.println(pattern3.matcher(str).find());
        String test ="021Abcf9Abcf1";

        System.out.println(isTrue(test));


    }


    public static boolean isTrue(String str){
        //判断是否包含长度超过3的子串
        int  len = 3;
        while (len <= str.length() / 2) {
            for (int i = 0; i <= str.length() - 2 * len; i++) {

                if (str.substring(i + len).contains(str.substring(i, len + i))) {
                    return true;
                }

            }
            len++;
        }
        return false;
    }

}
